Home:ALL Converter>Angular routing otherwise

Angular routing otherwise

Ask Time:2020-02-24T01:22:13         Author:dotteldu

Json Formatter

I'am writing an homepage using javascript, an express server and angular. Currently I have following routing:

function config($routeProvider) {
  $routeProvider
  .when('/', {
    templateUrl: '/login/login.view.html',
    controller: 'loginCtrl',
    controllerAs: 'vm'
  })
  .when('/home', {
    templateUrl: '/home/home.view.html',
    controller: 'homeCtrl',
    controllerAs: 'vm'
  })
  .otherwise({redirectTo: '/'});
}

Instead of the redirection in .otherwise to login page I would like that the user gets an page like:

Not found

The requested URL <requestedURL> was not found on this server.

How can I get the requested url in the controller of redirected page? Or what is the common way to implement this?

Kind regards, Wolfgang

Author:dotteldu,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/60364846/angular-routing-otherwise
yy